import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

const category = () => import(/* webpackChunkName: "category" */'../views/Category.vue')
const cart = () => import(/* webpackChunkName: "cart" */'../views/Cart.vue')
const user = () => import(/* webpackChunkName: "user" */'../views/User.vue')
const about = () => import(/* webpackChunkName: "about" */'../views/About.vue')
const detail = () => import(/* webpackChunkName: "detail" */'../views/Detail.vue')
const login = () => import(/* webpackChunkName: "login" */'../views/Login.vue')

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    redirect: 'home'
  },
  {
    path: '/home',
    name: 'home',
    meta: {
      index: 1 //添加meta属性，约定1为第一级
    },
    component: Home
  },
  {
    path: '/category',
    name: 'category',
    meta: {
      index: 1 //添加meta属性，约定1为第一级
    },
    component: category
  },
  {
    path: '/cart',
    name: 'cart',
    meta: {
      index: 1 //添加meta属性，约定1为第一级
    },
    component: cart
  },
  {
    path: '/user',
    name: 'user',
    meta: {
      index: 1 //添加meta属性，约定1为第一级
    },
    component: user
  },
  {
    path: '/about',
    name: 'about',
    meta: {
      index: 2 // 添加 meta 属性，约定 2 为第二级
    },
    component: about
  },
  {
    path: '/detail',
    name: 'detail',
    meta: {
      index: 2 // 添加 meta 属性，约定 2 为第二级
    },
    component: detail
  },
  {
    path: '/login',
    name: 'login',
    meta: {
      index: 2 // 添加 meta 属性，约定 2 为第二级
    },
    component: login
  },
]

const router = new VueRouter({
  routes
})

export default router